package com.rchat.pocmini.util;

import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;

import com.airtalkee.sdk.AirtalkeeAccount;

import static android.content.Context.ACTIVITY_SERVICE;

/**
 * Created by ljd on 2017/2/5.
 */

public class AppConfig {


    //服务器地址（IP地址）
    public static final String SERVER_ADDRESS = "118.178.32.100";
    //服务器端口
    public static final int SERVER_PORT = 4001;

    //============= TRACE_MODE值 ===========
//    //Log输出到LogCat
//    public static final int TRACE_MODE = AirtalkeeAccount.TRACE_MODE_ON_SCREEN;
    //Log输出到文件
//    public static final int TRACE_MODE = AirtalkeeAccount.TRACE_MODE_ON_FILE;
    //关闭Log模式（默认为此方式）
    public static final int TRACE_MODE = AirtalkeeAccount.TRACE_MODE_OFF;
    //============= TRACE_MODE值 ===========


    //是否开启实时音频的本地录制，录制的本地文件会自动保存在RECORD_MESSAGE_SAVE_PATH路径下
    public static final boolean MEDIA_REAL_TIME_RECORD_DISABLE = false;
    //设置语音本地缓存文件存放路径
    public static final String RECORD_MESSAGE_SAVE_PATH = "/com/rchat/pocmini/message_record/";
    //开启或关闭实时音频的本地录制
    public static final boolean SESSION_LOCAL_RECORD_ENABLE = true;


    public static void finishApp(Context context) {
        int currentVersion = android.os.Build.VERSION.SDK_INT;
        if (currentVersion > android.os.Build.VERSION_CODES.ECLAIR_MR1) {
            Intent startMain = new Intent(Intent.ACTION_MAIN);
            startMain.addCategory(Intent.CATEGORY_HOME);
            startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(startMain);
            System.exit(0);
        } else {// android2.1
            ActivityManager am = (ActivityManager) context.getSystemService(ACTIVITY_SERVICE);
            am.restartPackage(context.getPackageName());
        }
    }
}
